#define _CRT_SECURE_NO_WARNINGS 1

# include<bits/stdc++.h>
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<long long> arr1(n + 1), arr2(n + 1, INT_MIN);
    for (int i = 1; i <= n; ++i)    cin >> arr1[i];
    int t, k;
    cin >> t >> k;
    for (int i = 0; i < k; ++i)
    {
        int tmp = 0;
        cin >> tmp;
        arr2[tmp] = t;
    }

    for (int i = 1; i < m; ++i)
    {
        cin >> t >> k;
        for (int j = 0; j < k; ++j)
        {
            int tmp = 0;
            cin >> tmp;
            if (t - arr2[tmp] < arr1[tmp])
            {
                printf("Don't take %d at %d!\n", tmp, t);
            }
            arr2[tmp] = t;
        }
    }
    return 0;
}


# include<bits/stdc++.h>
using namespace std;

int main()
{
    int cnt = 0, ans = 0;
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; ++i)
    {
        int k = 0;
        cin >> k;
        if (k + cnt > m)
        {
            cnt = 0;
            ++ans;
        }
        cnt += k;
    }
    cout << ans;
    return 0;
}